﻿using MediatR;
using T.Basic.API.Appliction.Command.LineCommand;
using T.Basic.Repository.BasicInterface;

namespace T.Basic.API.Appliction.CommandHandlers.LineHanders
{
    /// <summary>
    /// 批删线路
    /// </summary>
    public class LineDeleteAllCommandHandler : IRequestHandler<LineDeleteAllCommand, int>
    {
        private readonly ILineRepository _lineRepository;
        public LineDeleteAllCommandHandler(ILineRepository lineRepository)
        {
            _lineRepository = lineRepository;
        }
        public async Task<int> Handle(LineDeleteAllCommand request, CancellationToken cancellationToken)
        {
            var LineIdd = request.Lineids;
            foreach (var item in LineIdd)
            {
                var lineDel= _lineRepository.GetModelsAsync(item).Result;
                lineDel.IsDeleted = true;
               
              await  _lineRepository.UpdateAsync(lineDel);

            }
            return 1;
        }
    }
}
